<template>
	<view class="pageBox">
		<view class="list">
			<view class="listItem" v-for="item in list" :key="item.id">
				<view class="time">
					{{ item.createdAt }}
				</view>
				<view class="item">
					<view class="itemMain flex-between">
						<view class="itemMainL flex-row">
							<view class="itemMainLL">
								交易所：
							</view>
							<view class="itemMainLR" v-if="item.exchange && item.exchange.parent">
								{{ item.exchange.parent.name }}
							</view>
						</view>
						<view class="itemMainR">
							{{ item.status == 0 ? "审核中" : item.status == 1 ? "审核通过" : item.status == -1 ? "审核拒绝" : "" }}
						</view>
					</view>
					
					<view class="itemMain flex-between">
						<view class="itemMainL flex-row">
							<view class="itemMainLL">
								票类：
							</view>
							<view class="itemMainLR" v-if="item.exchange">
								{{ item.exchange.name }}
							</view>
						</view>
					</view>
					
					<view class="itemMain flex-between">
						<view class="itemMainL flex-row">
							<view class="itemMainLL">
								数量：
							</view>
							<view class="itemMainLR">
								{{ item.money }}
							</view>
						</view>
					</view>
					
					<view class="itemMain flex-between" v-if="item.remark && item.status == -1">
						<view class="itemMainL flex-row">
							<view class="itemMainLL">
								备注：
							</view>
							<view class="itemMainLR colorPurple">
								{{ item.remark }}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<uni-load-more :status="listStatus"></uni-load-more>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: "",
				
				list: [],
				form: {
					page: 1,
					lastId: 0,
				},
				loading: false,
				finished: false,
			}
		},
		onLoad(option) {
			this.type = option.type;
			this.list = [];
			this.form.page = 1;
			this.form.lastId = 0;
			this.loading = false;
			this.finished = false;
			this.getList();
		},
		onReachBottom() {
			this.getList();
		},
		computed: {
			listStatus() {
				if (this.finished) return "noMore";
				if (this.loading) return "loading";
				return "more";
			}
		},
		methods: {
			getList() {
				if (this.loading || this.finished) return;
				this.loading = true;
				this.$post({
					module: 'Finance',
					interface: 7002,
					data: {
						type: this.type,
						...this.form
						},
				}).then(res => {
					this.list = this.list.concat(res.list);
					this.form.page = res.currentPage + 1;
					this.form.lastId = res.lastId;
					if (this.form.page > res.lastPage) {
						this.finished = true;
					}
					this.loading = false;
				}).catch(() => {
					this.loading = false;
				})
			},
		},
	}
</script>

<style scoped lang="scss">
	.pageBox {
		width: 100%;
		min-height: calc(100vh - var(--window-top));
		background-color: #f8f8f8;
		.list {
			padding: 32rpx;
			.listItem {
				margin-bottom: 32rpx;
				.time {
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #000000;
					line-height: 40rpx;
				}
				.item {
					margin-top: 32rpx;
					padding: 16rpx 32rpx;
					background-color: #ffffff;
					border-radius: 16rpx;
				}
				.itemMain {
					padding: 16rpx 0;
					.itemMainL {
						.itemMainLL {
							font-size: 28rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #000000;
							line-height: 40rpx;
						}
						.itemMainLR {
							font-size: 28rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #000000;
							line-height: 40rpx;
						}
						.colorPurple {
							color: #F2615F ;
						}
					}
					.itemMainR {
						font-size: 28rpx;
						font-family: PingFangSC-Semibold, PingFang SC;
						font-weight: 600;
						color: #F2615F;
						line-height: 40rpx;
					}
				}
			}
		}
	}
</style>